﻿using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL
{
    public class FangHao_DAL
    {
        public FangHao_DAL(Context context)
        {
            Context = context;
        }

        public Context Context { get; }

        /// <summary>
        /// 房号添加
        /// </summary>
        /// <param name="m"></param>
        /// <returns></returns>
        public int FangHaoAdd(FangHao_Model m)
        {
            var m1 = Context.FangHao_Model.FirstOrDefault(x => x.FH == m.FH);
            if (m1 != null)
            {
                return -1;  //房型名称重复
            }
            else
            {
                Context.FangHao_Model.Add(m);
                return Context.SaveChanges();
            }
        }
        /// <summary>
        /// 房号列表
        /// </summary>
        /// <returns></returns>
        public List<FangHao_Model> FangHaoShow()
        {
            return Context.FangHao_Model.ToList();
        }
       
    }
}
